package com.sense.kukoo.common.media.input

import com.sense.kukoo.common.media.Kukoo
import com.sense.kukoo.common.media.bean.LocalMediaListItemBean
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.launch

class UserInputImpl {

    fun play(book :LocalMediaListItemBean) {
        Kukoo.playlist.play(book)
    }

    fun delete(book :LocalMediaListItemBean){
        Kukoo.playlist.delete(book)
    }

    fun deleteAll(){
        Kukoo.playlist.deleteAll()
    }

    fun start(){
        Kukoo.play.start()
    }

    fun pause(){
        Kukoo.play.pause()
    }

    fun seekTo(userProgress:Int){
        Kukoo.play.seekTo(userProgress)
    }

    fun seekBy(milliseconds:Int){
        Kukoo.play.seekBy(milliseconds)
    }

    fun setSpeed(speed:Float){
        Kukoo.play.setSpeed(speed)
    }

    fun setTimer(type:Int){
        Kukoo.timer.setTimer(type)
    }

    private fun  inputEvent(block: suspend CoroutineScope.() -> Unit){
        GlobalScope.launch(Dispatchers.IO, block = block)
    }
}